//
//  LTMessage.h
//  LTIM
//
//  Created by 俊松何 on 2017/3/27.
//  Copyright © 2017年 俊松何. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "LTMessageBody.h"
#import "LTMessageTextBody.h"
#import "LTMessageImageBody.h"
#import "LTMessageVoiceBody.h"
#import "LTMessageVideoBody.h"
#import "LTMessageApplyBody.h"
#import "LTMessageLocationBody.h"
#import "LTMessageRedEnvelopeBody.h"
#import "LTMessageGroupOperationBody.h"
#import "LTMessageCmdBody.h"
#import "LTMessageGZHBody.h"
#import "LTMessageGzhShareBody.h"
#import "LTMessageFileBody.h"
#import "LTMessageLinkBody.h"
#import "LTMessageBigBqBody.h"
#import "LTMessageCallTipBody.h"
#import "LTMessagePersonCardBody.h"
#import "LTMessageLuckMoneyBody.h"
#import "LTMessageAtTextBody.h"
#import "LTMessageETHTransferBody.h"
#import "LTMessageLightUpBody.h"
#import "LTMessageGiftBody.h"
#import "LTMessageRoomOperationBody.h"
#import "LTMessageUpdateTitleBody.h"

/*!
 *  \~chinese
 *  消息cell类型
 *
 *  \~english
 *   Message Status
 */
typedef enum{
    
    LTMessageCellNone           = 0,
    LTMessageCellRecvText       = 1,
    LTMessageCellRecvImage      = 2,
    LTMessageCellRecvLocation   = 3,
    LTMessageCellRecvVoice      = 4,
    LTMessageCellRecvFile       = 5,
    LTMessageCellRecvVideo      = 6,
    LTMessageCellRecvRedBao     = 7,
    LTMessageCellRecvGzhShareCard = 8,
    LTMessageCellRecvMMText     = 9,
    LTMessageCellRecvGif        = 10,
    LTMessageCellRecvMMImage    = 11,
    LTMessageCellRecvLink       = 12,
    LTMessageCellRecBigBq       = 13,
    LTMessageCellRecvCallTip    = 14,
    LTMessageCellRecvPersonCard = 15,
    LTMessageCellRecvLuckMoney  = 16,
    LTMessageCellRecvAtText     = 17,
    LTMessageCellRecvETHTransfer = 18,
    LTMessageCellRecvSayHello    = 19,
    
    
    LTMessageCellSendText           = 41,
    LTMessageCellSendImage          = 42,
    LTMessageCellSendLocation       = 43,
    LTMessageCellSendVoice          = 44,
    LTMessageCellSendFile           = 45,
    LTMessageCellSendVideo          = 46,
    LTMessageCellSendRedBao         = 47,
    LTMessageCellSendGzhShareCard   = 48,
    LTMessageCellSendMMText         = 49,
    LTMessageCellSendGif            = 50,
    LTMessageCellSendMMImage        = 51,
    LTMessageCellSendLink           = 52,
    LTMessageCellSendBigBq          = 53,
    LTMessageCellSendCallTip        = 54,
    LTMessageCellSendPersonCard     = 55,
    LTMessageCellSendLuckMoney      = 56,
    LTMessageCellSendAtText         = 57,
    LTMessageCellSendETHTransfer    = 58,
    LTMessageCellSendSayHello       = 59,
    
    
}LTMessageCellType;

/*!
 *  \~chinese
 *  消息类型
 *
 *  \~english
 *   Message Status
 */

typedef enum{
    
    LTMessageTypeText             = 1000,
    LTMessageTypeImage            = 1003,
    LTMessageTypeVoice            = 1004,
    LTMessageTypeLocation         = 1005,
    LTMessageTypePersonCard       = 1006,  //个人名片
    LTMessageTypeLink             = 1007,
    LTMessageTypeFile             = 1008,
    LTMessageTypeVideo            = 1009,
    LTMessageTypeRedBao           = 1010,  //红包
    LTMessageTypeRECEIVERedBao    = 1011,  //领取红包消息
    LTMessageTypeNOPermission     = 1012,
    LTMessageTypeGzh              = 1013,  //公众号消息，(文章)
    LTMessageTypeShareGzh         = 1014,  //公众号文章分享
    LTMessageTypeBigBq            = 1015,  //表情MM
    LTMessageTypeCallTip          = 1016,  //消息提示
    LTMessageTypeLuckMoney        = 1017,  //lunckmoney红包
    LTMessageTypeAtText           = 1018,  //At消息
    LTMessageTypeETHTransfer      = 1019,  //虚拟币转账消息
    LTMessageTypeScreenShots      = 1020,  //截屏消息
    
    LTMessageTypeSayhello         = 1021,  //打招呼消息
    
    
    LTMessageTypeCMD               = 2000,  //cmd消息
    
    LTMessageTypeCreateGroup       = 2001,  //创建群
    LTMessageTypeaddGroupMember    = 2002,  //添加群成员
    LTMessageTypeaddGroupQRMember  = 2003,  //通过扫群二维码进群
    LTMessageTypedeleteGroupMember = 2004,  //群主删除群成员
    LTMessageTypechangeGroupName   = 2005,  //更改群名字
    LTMessageTypechangeGroupnotice = 2006,  //更改群公告
    LTMessageTypeMessageRevoke     = 2007,  //消息撤回的提示消息（接收到撤回消息透传，手动插入一条）
    LTMessageTypeQuitGroupMessage  = 2010,  //退出者先发送此条消息 退群消息
    
    LTMessageTypeAgreeApply        = 3000,  //好友申请消息类型
    
    LTMessageTypeLightUp           = 4000,  //直播间点亮消息
    LTMessageTypeBarrage           = 4001,  //弹幕消息
    LTMessageTypeGift              = 4002,  //礼物消息
    
    LTMessageTypeRoomNormal        = 4003,  //直播间普通文本消息
    LTMessageTypeRoomJoin          = 4004,  //进入直播间消息
    LTMessageTypeRoomSetManager    = 4005,  //设置为管理员
    LTMessageTypeRoomCancelManager = 4006,  //取消管理员
    LTMessageTypeRoomMute          = 4007,  //禁言用户
    LTMessageTypeRoomCancelMute    = 4008,  //取消禁言
    LTMessageTypeRoomKickout       = 4009,  //踢出用户
    LTMessageTypeRoomCancleKickout = 4010,  //踢出用户
    LTMessageTypeRoomUpdateTitle   = 4011,  //更新title
    LTMessageTypeRoomFocusHost     = 4012,  //用户关注了主播消息提示
    
    
    LTMessageTypeCloseLive         = 4050,  //主播关闭直播间发送的消息
    
}LTMessageType;

/*!
 *  \~chinese
 *  消息发送状态
 *
 *  \~english
 *   Message Status
 */
typedef enum{
    LTMessageStatusPending      = 0,    /*! \~chinese 发送未开始 \~english Pending */
    LTMessageStatusDelivering   = 1,      /*! \~chinese 正在发送 \~english Delivering */
    LTMessageStatusSuccessed    = 2,       /*! \~chinese 发送成功 \~english Successed */
    LTMessageStatusFailed       = 3,          /*! \~chinese 发送失败 \~english Failed */
    LTMessageStatusNoPermission = 4,          // 没有权限，被对方加入了黑名单
}LTMessageStatus;
/*!
 *  \~chinese
 *  消息方向
 *
 *  \~english
 *  Message direction
 */
typedef enum{
    LTMessageDirectionSend = 0,    /*! \~chinese 发送的消息 \~english Send */
    LTMessageDirectionReceive,     /*! \~chinese 接收的消息 \~english Receive */
}LTMessageDirection;

typedef enum{
    LTChatTypeChat          = 1000,   /*! \~chinese 单聊消息 \~english one to one chat type */
    LTChatTypeGroupChat     = 1001,    /*! \~chinese 群聊消息 \~english Group chat type */
    LTChatTypeChatTalkGroup = 1002, //讨论组
    LTChatTypeChatRoom      =  1003,     /*! \~chinese 聊天室消息 \~english Chatroom chat type */
    LTChatTypeChatGZH       = 1004 ,    // 公众号消息
    
    
}LTChatType;


typedef enum {
    
    LTNoticeMessageTypeFollowing  = 0,//关注更新
    
    LTNoticeMessageTypeLikes      = 1,     //被别人喜欢
    
    LTNoticeMessageTypeComments   = 2, //被别人评论
    
    LTNoticeMessageTypeFollower   = 3, //被别人关注
    
    LTNoticeMessageTypeRewards    = 4,  //被别人打赏
    
    LTNoticeMessageTypeMoments    = 5,   //朋友圈有更新
    
    LTNoticeMessageTypenuKnow     = 20,  //未知
    
    
} LTNoticeMessageType;


@interface LTMessage : NSObject

/** 消息serverID */
@property(nonatomic,  copy)  NSString  *messageId;

/** 消息所属会话id */
@property(nonatomic,  copy)  NSString  *conversationId;

/** 发送方的userid */
@property(nonatomic,  copy)  NSString  *sinceUserId;

/** 接受方的userid */
@property(nonatomic,  copy)  NSString  *targetUserId;

/** 发送方的LTUser json字符串 */
@property(nonatomic,  strong)  LTUser  *since;

/** 接收方的LTUser json字符串 */
@property(nonatomic,  strong)  LTUser  *target;

/** 聊天内容 消息body */
@property(nonatomic,  copy)  NSString *data;

/** 创建时间 */
@property(nonatomic,  assign)  long   createTime;

/** 消息服务器时间 */
@property(nonatomic,  assign)  long   serverTime;

/** 消息方向 */
@property(nonatomic,assign)  LTMessageDirection direction;

/** 消息类型 */
@property(nonatomic,assign)  LTMessageType messageType;

/** 消息聊天模式（单聊还是群) */
@property(nonatomic,assign)  LTChatType    chatType;

/** 消息发送状态 */
@property (nonatomic,assign) LTMessageStatus status;

/** 聊天翻译文本 */
@property(nonatomic,  copy)  NSString *transContent;

/** 额外字段 */
@property(nonatomic,  copy)  NSString *extra;

/** 消息body */
@property(nonatomic,strong)  LTMessageBody *body;

/** 消息cell的类型 */
@property(nonatomic,assign)  LTMessageCellType cellType;

/** 消息是否已读 */
@property(nonatomic,assign) BOOL isRead;

/** 数据jsonStr */
@property(nonatomic,  copy) NSString *datajsonStr;


/** 消息优先级 */
@property(nonatomic,assign) int level;

/**
 消息初始化

 @param conversationID 会话id(一般为会话对方的userid)
 @param fromUserId 消息发送方的userid
 @param toUserId 消息接收方的userid
 @param fromuser 消息发送方的user
 @param toUser 消息接收方的user
 @param type 消息类型
 @param body 消息体
 @param chattype 消息的聊天模式
 @param ext 附加字段
 @return   消息
 */
-(instancetype)initWithConversationID:(NSString *)conversationID
                           fromUserId:(NSString *)fromUserId
                             toUserId:(NSString *)toUserId
                             fromUser:(LTUser *)fromuser
                               toUser:(LTUser *)toUser
                                 type:(LTMessageType)type
                                 body:(LTMessageBody *)body
                             chatType:(LTChatType)chattype
                                  ext:(NSString *)ext;

-(void)markMessageAsRead;

@end
